 import java.util.ArrayList;
 import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

// HJ80 整型数组合并
public class HJ80 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int num = sc.nextInt();
            ArrayList<Integer> l1 = new ArrayList();
            for (int i = 0; i < num; i++) {
                l1.add(sc.nextInt());
            }
            int num2 = sc.nextInt();
            ArrayList<Integer> l2 = new ArrayList();
            for (int i = 0; i < num; i++) {
                if (l2.indexOf(l1.get(i)) == -1) {
                    l2.add(l1.get(i));
                }
            }
            l1 = l2;
            for (int i = 0; i < num2; i++) {
                int b = sc.nextInt();
                if (l1.indexOf(b) == -1) {
                    l1.add(b);
                }
            }
            l1.sort(Comparator.naturalOrder());
            for (int i = 0; i < l1.size(); i++) {
                System.out.printf(l1.get(i).toString());
            }
        }
    }
}

